<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
		<title></title>
		<script type="text/javascript" src="../../js/boot.js"></script>
	</head>

	<body>
		<div style="width:800px;">
			<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
				<table style="width:100%;">
					<tr>
						<td style="width:100%;">
							<a class="mini-button" iconCls="icon-add" onclick="addRow()" plain="true">增加</a>
							<span class="separator"></span>
							<a class="mini-button" iconCls="icon-remove" onclick="removeRow()" plain="true">删除</a>
							<span class="separator"></span>
							<a class="mini-button" iconCls="icon-save" onclick="saveData()" plain="true">保存</a>
						</td>
					</tr>
				</table>
			</div>
		</div>

		<div class="mini-fit">
			<div id="datagrid" class="mini-datagrid" style="width:100%;height:100%;" showPager="false" allowCellEdit="true" allowCellSelect="true" editNextOnEnterKey="true" editNextRowCell="true">
				<div property="columns">
					<div field="index" type="indexcolumn" width="15"></div>
					<div name="key" field="key" headerAlign="center" width="100">路径名称
						<input property="editor" class="mini-textbox" style="width:100%;" />
					</div>
					<div name="path" field="path" headerAlign="center" width="200">路径值
						<input property="editor" class="mini-textbox" style="width:100%;" />
					</div>
					<div name="mapping" field="mapping" headerAlign="center" width="100">映射地址
						<input property="editor" class="mini-textbox" style="width:100%;" />
					</div>
				</div>
			</div>
		</div>
	</body>

	<script type="text/javascript">
		miniInit();

		var gridData = null;
		var datagrid = mini.get("datagrid");
		http.get("/admin/boot/web/list.do", function(page) {
			if(page.success) {
				gridData = page.data;
				datagrid.setData(gridData);
			}
		});

		function addRow() {
			var newRow = {};
			var data = datagrid.getData();
			datagrid.addRow(newRow, data.length);
		}

		function removeRow() {
			var rows = datagrid.getSelecteds();
			if(rows.length > 0) {
				datagrid.removeRows(rows, true);
			}
		}

		function saveData() {
			mini.mask({
				el: document.body,
				cls: 'mini-mask-loading',
				html: '数据保存中...'
			});
			// debugger
			var json = mini.encode(datagrid.getData());
			var data = {
				"json": json
			};
			http.post("/admin/boot/web/save.do", data, function(page) {
				mini.unmask();
				if(page.success) {
					mini.alert("保存成功", "提示", null);
				} else {
					mini.alert("保存失败", page.message, null);
				}
			});
		}
	</script>

</html>